var i;
Object.defineProperty(exports, "__esModule", {
  value: true
});
var BundleConfig = require("AA_BundleConfig");
var EventManager = require("AA_EventManager");
var ResKeeper = require("AA_ResKeeper");
var EvenType = require("AA_EvenType");
var NodePoolMag = require("AA_NodePoolMag");
var UI_BaoZha = require("AA_UI_BaoZha");
var UI_FanWeiDong = require("AA_UI_FanWeiDong");
var _decorator = cc._decorator;
var _ccclass = _decorator.ccclass;
_decorator.property;

var _def_UI_GameOhterNode = function (e) {
  function _creator() {
    return null !== e && e.apply(this, arguments) || this;
  }
  __extends(_creator, e);
  _creator.prototype.onEnable = function () {
    EventManager.EventMgr.addEventListener(EvenType.EVENT_TYPE.Game_Add_BaoZha, this.onAddBao, this);
    EventManager.EventMgr.addEventListener(EvenType.EVENT_TYPE.Game_Add_FanWeiBaoZha, this.onAddFanWeiBingDong, this);
  };
  _creator.prototype.onAddFanWeiBingDong = function (e, t, o, n) {
    return __awaiter(this, undefined, undefined, function () {
      var i;
      var a;
      return __generator(this, function (r) {
        switch (r.label) {
          case 0:
            if (i = NodePoolMag.NodePoolMag.instance.getNode("fanweidong")) {
              return [3, 2];
            } else {
              return [4, this._loadRes(BundleConfig.BundleNames.Game, "game/" + "prefabs/effpre/UI_FanWeiDong", cc.Prefab)];
            }
          case 1:
            a = r.sent();
            NodePoolMag.NodePoolMag.instance.createNodeCount("fanweidong", 1, a);
            i = NodePoolMag.NodePoolMag.instance.getNode("fanweidong");
            r.label = 2;
          case 2:
            i.x = e.x;
            i.y = e.y;
            this.node.addChild(i);
            i.getComponent(UI_FanWeiDong.default).playBingDong(t, o, n);
            return [2];
        }
      });
    });
  };
  _creator.prototype.onAddBao = function (e, t, o) {
    undefined === t && (t = 1);
    return __awaiter(this, undefined, undefined, function () {
      var n;
      var i;
      var a;
      return __generator(this, function (r) {
        switch (r.label) {
          case 0:
            if (n = NodePoolMag.NodePoolMag.instance.getNode("baozha")) {
              return [3, 2];
            } else {
              return [4, this._loadRes(BundleConfig.BundleNames.Game, "game/" + "prefabs/effpre/UI_BaoZha", cc.Prefab)];
            }
          case 1:
            i = r.sent();
            NodePoolMag.NodePoolMag.instance.createNodeCount("baozha", 1, i);
            n = NodePoolMag.NodePoolMag.instance.getNode("baozha");
            r.label = 2;
          case 2:
            n.x = e.x;
            n.y = e.y;
            this.node.addChild(n);
            a = n.getComponent(UI_BaoZha.default);
            switch (t) {
              case 1:
                a.playBaoZa(o);
                break;
              case 2:
                a.playBingBao();
                break;
              case 3:
                a.playYinTaoBaoZha(o);
            }
            return [2];
        }
      });
    });
  };
  _creator.prototype.onDisable = function () {
    EventManager.EventMgr.rmEventListener(EvenType.EVENT_TYPE.Game_Add_BaoZha, this.onAddBao, this);
    EventManager.EventMgr.rmEventListener(EvenType.EVENT_TYPE.Game_Add_FanWeiBaoZha, this.onAddFanWeiBingDong, this);
  };
  return __decorate([_ccclass], _creator);
}(ResKeeper.default);
exports.default = _def_UI_GameOhterNode;